package com.meihua.shellapp.activity.set;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.lzy.okgo.OkGo;
import com.meihua.shellapp.R;
import com.meihua.shellapp.base.BaseActivity;
import com.meihua.shellapp.base.BaseBean;
import com.meihua.shellapp.base.MyApplication;
import com.meihua.shellapp.utils.MyStringCallBack;
import com.meihua.shellapp.utils.ToastUtils;
import com.meihua.shellapp.utils.URL;

import butterknife.Bind;

/**
 * 验证身份证号
 * 作者：lc on 2017/10/19.
 * 邮箱：lc0607live@163.com
 */

public class VerificatoinCardActivity extends BaseActivity {


    @Bind(R.id.iv_top_left)
    ImageView iv_top_left;//返回
    @Bind(R.id.tv_title)
    TextView tv_title;//标题

    @Bind(R.id.tv_message)
    TextView tv_message;//提示信息
    @Bind(R.id.et_card)
    EditText et_card;//身份证号
    @Bind(R.id.bt_next)
    Button bt_next;//下一步

    @Override
    public int getLayoutId() {
        return R.layout.activity_verificatoin_card;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        tv_title.setVisibility(View.VISIBLE);
        iv_top_left.setVisibility(View.VISIBLE);
        tv_title.setText("重置支付密码");
        iv_top_left.setOnClickListener(this);
        bt_next.setOnClickListener(this);
        tv_message.setText("填写" + MyApplication.getInstance().bean.getName() + "的身份证号验证身份");
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()) {
            case R.id.bt_next://下一步
                verificationCard();
                break;
        }
    }

    /**
     * 验证身份证号
     */
    private void verificationCard() {
        OkGo.<String>post(URL.getUrl().VERIFICATIONCARD)
                .params("m_number", MyApplication.getInstance().getUserId())
                .params("number", et_card.getText().toString())
                .execute(new MyStringCallBack<BaseBean>(bt_next) {
                    @Override
                    public void onSuccessData(BaseBean bean) {
                        super.onSuccessData(bean);
                        if (bean.getCode() == 1) {
                            Intent in = new Intent(mContext, VerificatoinCodeActivity.class);
                            startActivity(in);
                            finish();
                        } else {
                            ToastUtils.getInstance().showToast(bean.getMsg());
                        }
                    }
                });
    }

}
